#pragma once

#include "ExecutableNode.h"

#include "ExceptionHandler.h"

namespace uml {

ExecutableNode::ExecutableNode(const QString& umlType)
    : ActivityNode(umlType) {}

void ExecutableNode::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    ActivityNode::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(handlers_, "handlers", json, errorList);
}

void ExecutableNode::toJson(QJsonObject& json) {
    ActivityNode::toJson(json);
    JsonSerializable::toJsonArray(handlers_, "handlers", json);
}

/// <summary>
/// handlers getter
/// A set of ExceptionHandlers that are examined if an exception propagates out of
/// the ExceptionNode.
/// </summary>
vector<shared_ptr<ExceptionHandler>>& ExecutableNode::handlers() {
    return handlers_;
}

} // namespace uml
